﻿using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using OpenAdmin.Core.DbContextLocators;

namespace OpenAdmin.Core.Models;

/// <summary>
/// 用户角色表
/// </summary>
[Table("SysUserRole")]
public class SysUserRole : EntityRelation<ApplicationDbContextLocator>, IEntityTypeConfigure<SysUserRole, ApplicationDbContextLocator>
{
    /// <summary>
    /// 用户id
    /// </summary>
    public int UserId { get; set; }

    /// <summary>
    /// 角色id
    /// </summary>
    public int RoleId { get; set; }

    public void Configure(EntityTypeBuilder<SysUserRole> entityBuilder)
    {
        entityBuilder.HasKey(t => new { t.UserId, t.RoleId });
    }
}
